#include <iostream>
using namespace std;
using ll = long long;
int main() {

    ll n,m,a,b;
    cin>>n>>m>>a>>b;
    
    ll ret=0;
    for(ll i=0;i<=min(n/2,m);i++)
    {
        ll j=min(n-i*2,(m-i)/2);
        ret=max(ret,i*a+j*b);
    }
    cout<<ret<<endl;
    return 0;
}
